package indi.gao;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <p>Description:</p>
 * <p>Copyright: Copyright (c)2020$</p>
 * <p>Company: Tope</p>
 * <P>Created Date :2020$-04$-10$</P>
 * <P>@version 1.0</P>
 */
public class DateFormat {
    public static void main(String[] args) {
//1632470765630
        Date date = new Date(System.currentTimeMillis() - 24 * 60 * 60 * 1000);

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//
//        Date start = null;
//        try {
//            start = sdf.parse("2021-09-24 16:06:26");
//        } catch (ParseException e) {
//            e.printStackTrace();
//        }
//        System.out.println(start.getTime());
//        long l = countMilliSeconds(start, new Date());
//        System.out.println(l);
    }


    public static long countMilliSeconds(Date a, Date b) {
        return Math.abs(a.getTime() - b.getTime());
    }

    public static String getDayHourTime(long seconds) {
        long hour = seconds / 3600L;
        long minute = (seconds - 3600L * hour) / 60L;
        long second = seconds - 3600L * hour - 60L * minute;
        String dayHourTime = "";
        if (hour > 0L) {
            dayHourTime = dayHourTime + hour + "时";
        }

        if (minute > 0L) {
            dayHourTime = dayHourTime + minute + "分";
        }

        if (second >= 0L) {
            dayHourTime = dayHourTime + second + "秒";
        }

        return dayHourTime;
    }
}
